#include "zevent/event.hpp"
#include <cstdio>
ZEVT_TYPE(e1);
ZEVT_TYPE(e2, int);
ZEVT_TYPE(e3, int, int);

struct S {
  auto operator()() {
    using namespace zevent::sml;
    auto a1 = [] { printf("action1\n"); };
    auto a2 = [](const auto e) {
      const auto data = *e;
      printf("action2: %d\n", data);
    };
    auto a3 = [](const auto e) {
      const auto [d1, d2] = *e;
      printf("action3: %d %d\n", d1, d2);
    };
    // clang-format off
    return make_transition_table(
       *"s1"_s + zevt<e1> / a1 = "s2"_s
       ,"s2"_s + zevt<e2> / a2 = "s3"_s
       ,"s3"_s + zevt<e3> / a3 = X
    );
    // clang-format on
  }
};

int main() {
  using namespace zevent::sml;
  auto &s1 = Sm<S>::Create();
  e1::Publish();
  e1::Publish();
  e2::Publish(2);
  e3::Publish(3, 3);
  printf("State Machine is finished: %s\n", s1.IsState(X) ? "true" : "false");
  return 0;
}
